package com.ww.springboot.boot.baseTest.design.single;

/**
 * 描述： 双重检锁的饱汉模式
 *
 * @author 🧑 ‍wanwei
 * @since 2022-03-04 11:09
 */
public class SingletonDemo2 {

    private volatile static SingletonDemo2 singletonDemo2;

    public static SingletonDemo2 instance() {
        if (singletonDemo2 == null) {
            synchronized (SingletonDemo2.class) {
                if (singletonDemo2 == null) {
                    singletonDemo2 = new SingletonDemo2();
                }
            }
        }
        return singletonDemo2;
    }
}
